home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / coreaids.zip / DIR_FILE.ASM < prev    next >
Assembly Source File  |  1987-06-26  |  6KB  |  204 lines

  1. ;    DESC:    Creates a file with a descriptive listing of all     V1.00
  2. ;    files matching the search string. The search string is in the format
  3. ;    of a filename. The filename may be specified with both the *
  4. ;    and ? wildcard characters. The listing file is in file Filelist.Dir.
  5. ;    The format of the files to be listed must be as
  6. ;    follows to list properly.
  7. ;    1) Text starts at Line One.
  8. ;    2) Each line begins with eight spaces or characters before the text.
  9. ;    3) Each line ends on or before the 78th column.
  10. ;    4) The listing portion of the file ends with all number signs {#}.
  11. ;    5) The entire listing is no more than 5000 bytes {approx. 50 lines.}
  12. ;    IN:    *filename.ext with wildcards allowed.
  13. ;    OUT:    *file called "FILELIST.DIR" with listing of all files
  14. ;        fitting conditions specified in search.
  15. ;    SAMPLE:    DIR_FILE *.ASM {all files with a .ASM extension}
  16. ;    ####################################################################
  17.  
  18.  
  19. DIR_FILD Segment Para Public 'DATA'
  20.         DW    0            ;help message.
  21.         DW    0
  22.         DD    MHELP
  23.         DW    EHELP
  24. MHELP        DB    0DH,0AH,'               '
  25.         DB    'DESC:   Creates a file with a descriptive listing of'
  26.         DB    0DH,0AH,'               '
  27.         DB    'all files matching the search string. The search'
  28.         DB    0DH,0AH,'               '
  29.         DB    'string is in the format of a filename. The filename'
  30.         DB    0DH,0AH,'               '
  31.         DB    'may be specified with both the * and ? wildcard'
  32.         DB    0DH,0AH,'               '
  33.         DB    'characters. The listing file is in file Filelist.Dir'
  34.         DB    0DH,0AH,'               '
  35.         DB    'The format of the files to be listed must be as'
  36.         DB    0DH,0AH,'               '
  37.         DB    'follows to list properly.'
  38.         DB    0DH,0AH,'               '
  39.         DB    '1) Text starts at Line One.'
  40.         DB    0DH,0AH,'               '
  41.         DB    '2) Each line begins with eight spaces or characters'
  42.         DB    0DH,0AH,'               '
  43.         DB    'before the text.'
  44.         DB    0DH,0AH,'               '
  45.         DB    '3) Each line ends on or before the 78th column.'
  46.         DB    0DH,0AH,'               '
  47.         DB    '4) The listing portion of the file ends with all'
  48.         DB    0DH,0AH,'               '
  49.         DB    'number signs {#}. {At least two}'
  50.         DB    0DH,0AH,'               '
  51.         DB    '5) The entire listing is no more than 5000 bytes'
  52.         DB    0DH,0AH,'               '
  53.         DB    '{approx. 50 lines.}'
  54.         DB    0DH,0AH,'               '
  55.         DB    'IN:     filename.ext with wildcards allowed.'
  56.         DB    0DH,0AH,'               '
  57.         DB    'OUT:    file called "FILELIST.DIR" with listing of'
  58.         DB    0DH,0AH,'               '
  59.         DB    'all files fitting conditions specified in search.'
  60.         DB    0DH,0AH,'               '
  61.         DB    'SAMPLE: DIR_FILE *.ASM {all files ending with .ASM}.'
  62. EHELP        DB    0
  63.  
  64. DATE        DW    0            ;date file last modified.
  65. SIZEHI        DW    0            ;high word of file size.
  66. SIZELO        DW    0            ;low word of file size.
  67.  
  68.  
  69. INHNDL        DW    0            ;input file handle.
  70.  
  71. OUTFILE        DB    'Filelist.Dir',0    ;output file name.
  72. OUTHNDL        DW    0            ;output file handle.
  73.  
  74. S1        DW    0            ;filesize blocks.
  75. S2        DW    0
  76. S3        DW    0
  77. S4        DW    0
  78. S5        DW    0
  79. CR        DW    0A0DH            ;carriage return.
  80.  
  81. FILLER        DB    20 Dup(20H)        ;blank filler.
  82.  
  83. BUFFER        DB    5000 Dup(0)        ;entry buffer.
  84. DIR_FILD Ends
  85.  
  86.     Extrn    SRCH_FIL:Near            ;locate files matching the
  87.                         ;search string.
  88.     Extrn    ERRORMSG:Near            ;prints error exit messages.
  89.     Extrn    OPEN:Near                ;opens file.
  90.     Extrn    CREATE:Near            ;creates a file.
  91.     Extrn    FILEDATE:Near            ;converts file date to ASCII.
  92.     Extrn    WRITE:Near            ;writes to a file.
  93.     Extrn    HEX_ASC:Near            ;converts hex to ASCII.
  94.     Extrn    SCAN_WRD:Near            ;scans for matching strings.
  95.     Extrn    SCAN_BYT:Near            ;scans for matching bytes.
  96.     Extrn    READ:Near            ;reads from data file.
  97.     Extrn    SRCH_NXT:Near            ;searches for next match.
  98.     Extrn    CLOSE:Near            ;closes data files.
  99.     Extrn    HELP:Near            ;provides help information.
  100.  
  101. DIR_FILC    Segment Para Public 'CODE'
  102.     Assume CS:DIR_FILC,DS:DIR_FILD
  103.  
  104.     Include    CALLM.MAC            ;macro file which allows
  105.                         ;input and output of
  106.                         ;parameters to subroutines.
  107.     DW    0,0,0,180,0,0,0
  108.  
  109.                         ;notice.
  110.     DB    'DIR_FILE - V1.00, Copyright 1987, CoreTechs   ',0DH,0AH
  111.  
  112. DIR_FILE    Proc    Far            ;main procedure.
  113.  
  114.     Push    DS                ;store return address.
  115.     Xor    AX,AX
  116.     Push    AX
  117.  
  118.     Mov    BX,DS                ;save initial data segment.
  119.  
  120.     Mov    AX,DIR_FILD            ;assign data segment location.
  121.     Mov    DS,AX
  122.  
  123.     Callm    HELP,<BX,AX>,<ES,BX,CX>        ;get DOS data line
  124.                         ;specifying files on which
  125.                         ;to make listing.
  126.  
  127.     Mov    CX,20H                ;locate first filename.
  128.     Callm    SRCH_FIL,<ES,BX>,<AX,DATE,SIZELO,SIZEHI,ES,BX,CX>
  129.     Jcxz    ERROR1                ;exit if no matching files.
  130.     Jmp    CONT1
  131.  
  132. ERROR1:    Callm    ERRORMSG,<2>,            ;display no File(s) found.
  133.  
  134.                         ;create output file.
  135. CONT1:    Callm    CREATE,<DS,<OFFSET OUTFILE>,0>,<OUTHNDL>
  136.  
  137. CONT2:    Callm    OPEN,<ES,BX,0>,<INHNDL>        ;open input file.
  138.  
  139.     Callm    WRITE,<OUTHNDL,CX,ES,BX>,<AX>    ;write the filename to file.
  140.  
  141.     Mov    AX,20                ;pad with blanks.
  142.     Sub    AX,CX                ;fill in string.
  143.                         ;write filler.
  144.     Callm    WRITE,<OUTHNDL,AX,DS,<OFFSET FILLER>>,<AX>
  145.  
  146.     Callm    FILEDATE,<DATE>,<AX,BX>        ;convert filedate to ASCII.
  147.  
  148.                         ;write the filedate to file.
  149.     Callm    WRITE,<OUTHNDL,8,AX,BX>,<AX>
  150.  
  151.                         ;get file size in ASCII.
  152.     Callm    HEX_ASC,<SIZEHI,SIZELO>,<S1,S2,S3,S4,S5>
  153.  
  154.     Mov    AX,S1                ;flip numbers.
  155.     Xchg    AH,AL
  156.     Mov    S1,AX
  157.     Mov    AX,S2                ;flip numbers.
  158.     Xchg    AH,AL
  159.     Mov    S2,AX
  160.     Mov    AX,S3                ;flip numbers.
  161.     Xchg    AH,AL
  162.     Mov    S3,AX
  163.     Mov    AX,S4                ;flip numbers.
  164.     Xchg    AH,AL
  165.     Mov    S4,AX
  166.     Mov    AX,S5                ;flip numbers.
  167.     Xchg    AH,AL
  168.     Mov    S5,AX
  169.  
  170.     Callm    WRITE,<OUTHNDL,12,DS,<OFFSET S1>>,<AX>    ;write file size.
  171.  
  172.                         ;read entry.
  173.     Callm    READ,<INHNDL,5000,DS,<OFFSET BUFFER>>,<CX>
  174.  
  175.     Cld                    ;perform forward search for
  176.                         ;multiple periods.
  177.     Callm    SCAN_WRD,<DS,<OFFSET BUFFER>,2323H,1>,<AX,CX>
  178.  
  179.     Std                    ;search for previous return.
  180.     Callm    SCAN_BYT,<DS,CX,000DH,1>,<AX,CX>
  181.  
  182.     Sub    CX,OFFSET BUFFER        ;find length of entry.
  183.  
  184.                         ;write entry to file.
  185.     Callm    WRITE,<OUTHNDL,CX,DS,<OFFSET BUFFER>>,<AX>
  186.  
  187.                         ;add carriage returns.
  188.     Callm    WRITE,<OUTHNDL,2,DS,<OFFSET CR>>,<AX>
  189.     Callm    WRITE,<OUTHNDL,2,DS,<OFFSET CR>>,<AX>
  190.  
  191.     Callm    CLOSE,<INHNDL>,            ;close input file.
  192.  
  193.     Mov    CX,20H                ;locate first filename.
  194.     Callm    SRCH_NXT,<ES,BX>,<AX,DATE,SIZELO,SIZEHI,ES,BX,CX>
  195.     Jcxz    ERROR2                ;exit if no more files.
  196.     Jmp    CONT2                ;return to start of loop.
  197.  
  198. ERROR2:    Callm    CLOSE,<OUTHNDL>,        ;close listing file.
  199.     Callm    ERRORMSG,<18>,            ;display no More Files(s).
  200.  
  201. DIR_FILE    Endp
  202. DIR_FILC    Ends
  203.     End    DIR_FILE
  204.